package org.jxc.service;
 

import java.util.List;

import org.hibernate.SessionFactory;
import org.jxc.dao.BackPurchaseProductDAO;
import org.jxc.domain.BackPurchaseProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.team4.dao.DAOFactory;
import org.team4.exception.CRUDException;
import org.team4.service.IService;
import org.team4.vo.Page;

public class BackPurchaseProductService implements IService {

	private BackPurchaseProductDAO backPurchaseProductDAO ;
	
	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		backPurchaseProductDAO = (BackPurchaseProductDAO) DAOFactory.getDAO(sessionFactory, BackPurchaseProductDAO.class);
	}

	public Page<BackPurchaseProduct> listPagination(Page<BackPurchaseProduct> page) throws CRUDException {
		return backPurchaseProductDAO.pagination(page, "from BackPurchaseProduct where deleteFlag = '0'", null);
	}

	public void save(BackPurchaseProduct object) throws CRUDException {
		backPurchaseProductDAO.save(object);
	}

	public List<BackPurchaseProduct> getListByBackPurchaseId(String backPurchaseId) throws CRUDException {
		return backPurchaseProductDAO.find
		(" from BackPurchaseProduct where backPurchase.id = '" + backPurchaseId  +"'", null);
	}

	public BackPurchaseProduct findById(String id) throws CRUDException {
		return backPurchaseProductDAO.get(id);
	}

	public void update(BackPurchaseProduct backPurchaseProduct) throws CRUDException {
		backPurchaseProductDAO.update(backPurchaseProduct);
	}

}
